Skip to main content

Reference

BrainAI

Manages chat sessions with Rezolve AI. Lives as a property on either BDLocationManager (iOS) or ServiceManager (Android).

iOS

let brainAI = BDLocationManager.instance.brainAI

Android

val brainAI = ServiceManager.getInstance(context).brainAI

Public Methods

MethodDescription
createNewChat()Creates a new Chat session and returns the object.
getChatWithSessionID(sessionID: ...)Retrieves an existing Chat session by its unique identifier.
closeChatWithSessionID(sessionID: ...)Closes (removes) a given Chat session to free resources.

Chat

Represents a single chat session. Responsible for sending messages and receiving real-time (streaming) responses.

Public Methods

MethodPlatformDescription
sendMessage(message: String)iOSSends a message; returns an AsyncThrowingStream<StreamingResponseDto, Error>. A closure-based version is also available for earlier iOS versions.
sendMessage(message: String)AndroidSends a message in Android; returns a Sequence (Kotlin) or Stream (Java) of StreamingResponseDto.

Public Properties

PropertyTypeDescription
sessionIDStringUnique session identifier (e.g., urn:uuid:9a652678-4616-475d-af12-aca21cfbe06d).
userIDStringDefaults to an installation reference. Useful for tracking which user initiated the chat.
languageStringDefaults to "English". Set this to customise the language context for your queries.

StreamingResponseDto

A wrapper for each partial chunk of the chat’s streaming response.

Public Properties

PropertyTypeDescription
responseStringThe text content of the current response chunk.
responseIDStringUnique identifier for the response chunk (if needed).
contextsArray of BDStreamingResponseDtoContext (Android) or ChatContext (iOS)List of additional context objects.
streamTypeIntegerIndicates the type of stream chunk ( 1 = CONTEXT, 2 = RESPONSE_TEXT, 3 = RESPONSE_IDENTIFIER).

Contexts in StreamingResponseDto

A critical feature of Rezolve AI is its ability to return contextual product information alongside the text response. This is especially useful when building digital shopping experiences, allowing the model to reference specific items, categories, or merchants in real time.

iOS: ChatContext

When you receive a context chunk on iOS, you’ll typically deal with an array of ChatContext objects. Each object provides details about a product or item that matches the user’s query.


Public Properties

PropertyTypeDescription
titleStringProduct or suggestion title.
imageLinks[URL]List of product/category image URLs.
priceNSNumberPrice of the product.
contextDescriptionStringA descriptive text for the product or suggestion.
merchantIDNSNumberMerchant identifier.
categoryIDNSNumberCategory identifier.
productIDNSNumberProduct identifier, which you can link to your backend.

Android: BDStreamingResponseDtoContext

On Android, context chunks are represented by BDStreamingResponseDtoContext objects.

Public Properties

PropertyTypeDescription
titleStringProduct or suggestion title, if available.
image_linksArray<String>List of image URLs related to the product or category.
priceDoubleProduct price.
descriptionStringText describing the product or suggestion.
merchant_idIntMerchant identifier.
category_idIntCategory identifier.
product_idIntProduct identifier for linking to your database or backend systems.

How Contexts Are Used

  1. Product Listing or Recommendations If the AI determines the user is asking about a product or category, it can return one or more Context entries, each describing an item that matches the user’s query.
  2. Dynamic UI Updates Use the context data to display product cards, images, prices, and other attributes in real time. For instance, you might show a carousel of recommended items based on the user’s latest question.
  3. Cross-Referencing The merchant_id, category_id, and product_id fields can tie back into your app’s internal product catalog. This way, when a user selects a product from the AI’s suggestion, you can seamlessly transition to a product details page or add it to a shopping cart.